package manager;

import java.util.ArrayList;
import java.util.List;

import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;

public class ServiceCodeManager {

	public static void main(String[] args) {
		getStandardFileManager();
	}
	
	public static void getStandardFileManager(){
		//Get an instance of java compiler
		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

		//Get a new instance of the standard file manager implementation
		StandardJavaFileManager fileManager = compiler.
		        getStandardFileManager(null, null, null);
		        
		// Get the list of java file objects, in this case we have only 
		// one file, TestClass.java
		
		List<String> fileNames = new ArrayList<String>();
		fileNames.add("MapManager.java");
		Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromStrings(fileNames);
		// Create the compilation task
		CompilationTask task = compiler.getTask(null, fileManager, null,
		                                        null, null, compilationUnits1);
		                                        
		// Perform the compilation task.
		task.call();
	}
}
